package com.cqhfan.authservice.controller;

import com.cqhfan.authservice.service.AuthService;
import com.cqhfan.pojo.user.dto.UserLoginDTO;
import com.cqhfan.pojo.user.vo.UserLoginVO;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author 眭传洪
 * @create 2025-07-25 1:56
 */
@RestController
@RequestMapping("/auth")
@RequiredArgsConstructor
public class AuthController {

    private final AuthService authService;

    @PostMapping("/sendMessageCode/{phone}")
    public void sendMessageCode(@PathVariable("phone") String phone) {
        authService.sendMessageCode(phone);
    }

    @PostMapping("/user/login")
    public UserLoginVO userLogin(@RequestBody UserLoginDTO loginBody) {
        return authService.userLogin(loginBody);
    }

    @PostMapping("/refreshToken")
    public UserLoginVO refreshToken(@RequestHeader("refreshToken") String refreshToken) {
        return authService.refreshToken(refreshToken);
    }

}
